<template>
  <div>
    <!-- 基本信息 -->
    <div v-for="(item, index) in overviewData" :key="index" class="mb-5">
      <el-descriptions
        :column="2"
        border
        class="margin-top"
        title="With border"
      >
        <template #title>
          <TitleName
            :title="item.title"
            class="title"
            icon="i-carbon-bookmark-filled"
          ></TitleName>
        </template>
        <el-descriptions-item
          v-for="(t, i) in item.list"
          :key="i"
          :label="t.label"
          class-name="w-8/24"
          label-align="right"
          label-class-name="w-4/24"
        >
          <!--      招标单位        -->
          <template v-if="t.prop === 'tenderer'">
            <dict-tag
              :isTag="false"
              :options="bidding_unit"
              :value="overviewInfo[t.prop]"
            />
          </template>
          <!--      项目阶段        -->
          <template v-else-if="t.prop === 'proSchedule'">
            <dict-tag
              :isTag="false"
              :options="project_phase"
              :value="overviewInfo[t.prop]"
            />
          </template>
          <!--      招标结果        -->
          <template v-else-if="t.prop === 'biddingResult'">
            <div
              v-if="overviewInfo[t.prop]"
              class="text-center leading-30px bg-#e7f3ff rounded-4px text-#1890ff border-1 border-solid border-#d0e8ff w-80px"
            >
              {{ overviewInfo[t.prop] == '1' ? '中标' : '未中标' }}
            </div>
          </template>
          <!--      招标形式       -->
          <template v-else-if="t.prop === 'tenderType'">
            <dict-tag :options="bidding_form" :value="overviewInfo[t.prop]" />
          </template>
          <template
            v-else-if="
              t.prop === 'gpRate' ||
              t.prop === 'bidOpeningTime' ||
              t.prop === 'proSumResouce'
            "
          >
            {{ overviewInfo[t.prop] }}
          </template>
          <template
            v-else-if="
              t.prop === 'pbDeadline' ||
              t.prop === 'proPaymentDeadline' ||
              t.prop === 'bidBondDeadline' ||
              t.prop === 'qgDeadline'
            "
          >
            {{ overviewInfo[t.prop] == '0' ? '-' : overviewInfo[t.prop] }}
          </template>
          <template v-else>{{
            overviewInfo[t.prop] != null ? overviewInfo[t.prop] + '万元' : ''
          }}</template>
        </el-descriptions-item>
        <el-descriptions-item :span="2" label="招标文件" label-align="right">
          <div
            v-for="files in overviewInfo['sysAttachFiles']"
            :key="files.fileId"
            class="inline-block"
          >
            <a :href="files.url" class="mr-10px text-#1890ff" target="_blank">{{
              files.origFileName
            }}</a>
          </div>
        </el-descriptions-item>
        <el-descriptions-item :span="2" label="中标通知书" label-align="right">
          <div
            v-for="files in overviewInfo['sysAttachFiles2']"
            :key="files.fileId"
            class="inline-block"
          >
            <a :href="files.url" class="mr-10px text-#1890ff" target="_blank">{{
              files.origFileName
            }}</a>
          </div>
        </el-descriptions-item>
      </el-descriptions>
      <!-- 投标项目评分情况 -->
      <TitleName
        class="title mt-30px"
        icon="i-carbon-bookmark-filled"
        title="投标项目评分情况"
      ></TitleName>
      <Scoring
        ref="scoringChind"
        :scaleMarkVos="scaleMarkVos ? scaleMarkVos : []"
      ></Scoring>
    </div>
  </div>
</template>

<script name="TenderInfos" setup>
import { getCurrentInstance, useAttrs } from 'vue'
import { useRouter } from 'vue-router'
import Scoring from '../../addProject/module/scoring.vue'
import {
  project_phase, //项目阶段
  bidding_unit,
  bidding_form //招标形式
} from '@/hooks/dict/useProject'
const router = useRouter()
const attrs = useAttrs()
const { proxy } = getCurrentInstance()
// 接受父级传递的参数
const props = defineProps({
  baseDetail: {
    required: true,
    type: Object || Array,
    default: () => {
      return {}
    }
  },
  financeDetail: {
    required: true,
    type: Object || Array,
    default: () => {
      return {}
    }
  },
  biddingDetail: {
    required: true,
    type: Object || Array,
    default: () => {
      return {}
    }
  },
  scaleMarkVos: {
    required: true,
    type: Array
  }
})
watchEffect(
  () => {
    overviewInfo.value = {
      ...props.baseDetail,
      ...props.financeDetail,
      ...props.biddingDetail
    }
  },
  {
    flush: 'post'
  }
)

const data = reactive({
  contractParam: {},
  //详情的数据
  overviewInfo: {},
  overviewData: [
    {
      title: '基本信息',
      list: [
        // { label: '投标单位', prop: 'tenderer' },
        { label: '投标结果', prop: 'biddingResult' },
        { label: '项目规模', prop: 'projectScale' },
        { label: '招标形式', prop: 'tenderType' },
        { label: '开标时间', prop: 'bidOpeningTime' },
        { label: '最终中标项目金额', prop: 'biddingSum' },
        { label: '项目资金来源', prop: 'proSumResouce' },
        { label: '项目付款期限', prop: 'proPaymentDeadline' },
        { label: '投标保证金', prop: 'bidBond' },
        { label: '投标保证金期限', prop: 'bidBondDeadline' },
        { label: '中标服务费金额', prop: 'bidServiceFee' },
        { label: '投标其他费用', prop: 'bidOtherCost' },
        { label: '投标项目预计成本总价', prop: 'totalEstCost' },
        { label: '项目拟投标报价', prop: 'tenderOffer' },
        { label: '其中:硬件产品采购价', prop: 'hpPrice' },
        { label: '其中:硬件产品拟报价', prop: 'hardwareOffer' },
        { label: '软件产品成本(含开发)', prop: 'softwareCost' },
        { label: '软件产品拟报价', prop: 'softwareOffer' },
        { label: '实施费用成本', prop: 'impCost' },
        { label: '实施费用拟报价', prop: 'impOffer' },
        { label: '质保金的金额', prop: 'qgAmount' },
        { label: '履约保证金', prop: 'pb' },
        { label: '质保金的期限', prop: 'qgDeadline' },
        { label: '履约保证金期限', prop: 'pbDeadline' },
        { label: '投标项目毛利', prop: 'gm' },
        { label: '毛利率', prop: 'gpRate' }
      ]
    }
  ]
})
const { contractParam, overviewData, overviewInfo } = toRefs(data)
</script>

<style lang="scss" scoped></style>
